<template>
    <div class="login-container">
        <div class="top">
            <img src="@/assets/tx.png" class="logo">
            <p class="title">| 波吉服饰商城</p>
        </div>

        <div class="loginbox">
            <h2 style="margin-bottom: 20px;">登录</h2>
            <el-form ref="loginFormRef" :model="userInfo" class="login-form">
                <el-form-item prop="account">
                    <el-input v-model="userInfo.phoneNumber" @change="change" placeholder="请输入用户名"
                        suffix-icon="el-icon-user" size="large" />
                </el-form-item>

                <el-form-item prop="password">
                    <el-input v-model="userInfo.password" @change="change" type="password" placeholder="请输入密码"
                        suffix-icon="Lock" size="large" show-password />
                </el-form-item>

                <div class="remember-forgot">
                    <el-checkbox v-model="userInfo.remember">记住我</el-checkbox>
                    <el-link type="primary" :underline="false">忘记密码？</el-link>
                </div>

                <button type="button" class="login-button" size="large" @click="doLogin">登录</button>

            </el-form>
        </div>
    </div>
</template>

<script>
import { login } from '@/apis/login'
export default {
    data() {
        return {
            userInfo: {
                phoneNumber: '13566789090',
                password: '123456'
            },
        }
    },
    methods: {
        async doLogin() {
            const res = await login(this.userInfo)
            if (res.status=='success') {
                this.$store.commit('user/setUserInfo',res.data)
                this.$router.push('/layout/home')
            }
        },
    },
    created() {

    },
    watch: {
        // 'userInfo.remember'(newValue) {
        //     if (newValue) {
        //         localStorage.setItem('userRemeber', JSON.stringify(this.userInfo))
        //     } else {
        //         localStorage.removeItem('userRemeber')
        //     }
        // }
    }

}
</script>


<style scoped>
.login-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('../../assets/th.png');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: 50%;

}

.top {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: absolute;
    top: 30px;
    left: 50px;
}

.logo {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    border-radius: 32px;
}

.title {
    font-size: 1.6em;
    font-weight: bold;
    color: #383b3b;
}


.loginbox {
    position: absolute;
    right: 15%;
    width: 25%;
    padding: 40px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 0 10px 10px #f0f4ff;


}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h2 {
    font-size: 28px;
    color: #1a1a1a;
    margin-bottom: 8px;
    font-weight: 600;
}

.subtitle {
    color: #666;
    font-size: 14px;
}



.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.login-button {
    width: 100%;
    height: 44px;
    font-size: 16px;
    background: #5EB87D;
    border: none;
    color: white;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.login-button:hover {
    background: #7fe6a3;
    transform: translateY(-1px);
}

input {
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    /* 不受padding影响 */
    border: 0;
    border-radius: 5px;
    background: #5eb87e80;
    transition: all 1s;
    outline: none;
}

::v-deep .el-input__inner {
    width: 100%;
    height: 45px;
    box-sizing: border-box;
    /* 不受padding影响 */
    border: 0;
    border-radius: 5px;
    background: #F7F8FC;
    transition: all 1s;
    outline: none;
}
</style>
